<?php

namespace App\Guards;

use App\Models\AdminUser;
use App\Models\Post;
use App\Models\Comment;

class AdminGuard {
    public static function is_superadmin(AdminUser $u){
        return $u->admin_type == AdminUser::SUPER_ADMIN;
    }

    public static function can_admin_manage_post(AdminUser $u, Post $post){
        return AdminGuard::is_superadmin($u) ||
            $u->luo_id == $post->luo->id;
    }

    public static function can_admin_manage_comment(AdminUser $u, Comment $comment){
        return AdminGuard::is_superadmin($u) ||
            $u->luo_id == $comment->post->luo->id;
    }
}
